Change in openvpn[master]: redirect-gateway: add route toward new remote host when using persist...
A message that is not in the archive (sent off-list or not yet received): gerrit.1740476883000.Ic7b486ccb85df7fc1d6a573ac1315d235728822c@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
to review the following change.
Change subject: redirect-gateway: add route toward new remote host when using persist-tun
......................................................................
redirect-gateway: add route toward new remote host when using persist-tun
When both --redirect-gateway and --persist-tun are used together, a route must be added for each new remote host we attempt to connect to.
---
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
3 files changed, 188 insertions(+), 22 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/901/1
src/openvpn/init.c +20 -0
@@ -2184,6 +2184,10 @@"route-pre-down" , c->c2.es); +if (c->mode ==CM_P2P && c->options.persist_tun) + { +del_route_towards_remote (c); + }delete_routes (c->c1.route_list, c->c1.route_ipv6_list, c->c1.tuntap,ROUTE_OPTION_FLAGS (&c->options), c->c2.es, &c->net_ctx);
@@ -2245,6 +2249,11 @@ c->c2.es); } +if (c->mode ==CM_P2P && c->options.persist_tun) + { +del_route_towards_remote (c); + } +del_wfp_block (c, adapter_index); }gc_free (&gc);
@@ -4825,6 +4834,17 @@ } } +/** +* When using both --redirect-gateway and --persist-tun, +* if the connection to the server is lost, a /32 (or /128 if IPv6) route must be added +* to ensure connectivity to the next remote. +*/ +if (c->mode ==CM_P2P + && c->options.persist_tun) + { +add_route_towards_remote (c); + } +/* * Actually do UID/GID downgrade, and chroot, if requested. * May be delayed by --client, --pull, or --up-delay.
src/openvpn/route.c +157 -22
219 lines not on this page · raw message
src/openvpn/route.h +11 -0
@@ -286,6 +286,14 @@ const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx); +/* Function to add a route towards the new remote when using +* `--redirect-gateway` and `--persist-tun` options together. */ +void add_route_towards_remote (struct context *c); + +/* Function to delete the route towards the remote when using +* `--redirect-gateway` and `--persist-tun` options together. */ +void del_route_towards_remote (struct context *c); + void add_route_to_option_list(struct route_option_list *l, const char *network, const char *netmask,
@@ -353,6 +361,9 @@const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6); +/* Return a `route_ipv6 *` /128 IPv6 route toward the remote host */ +struct route_ipv6 *create_host_route_ipv6 (struct in6_addr remote_host_ipv6,struct route_ipv6_list *rl6); +/* * Test if addr is reachable via a local interface (return ILA_LOCAL), * or if it needs to be routed via the default gateway (return
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7b486ccb85df7fc1d6a573ac1315d235728822c
Gerrit-Change-Number: 901
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
to look at the new patch set (#2).
Change subject: redirect-gateway: add route toward new remote host when using persist-tun
......................................................................
redirect-gateway: add route toward new remote host when using persist-tun
When both --redirect-gateway and --persist-tun are used together, a route must be added for each new remote host we attempt to connect to.
---
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
3 files changed, 187 insertions(+), 22 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/901/2
src/openvpn/init.c +20 -0
@@ -2101,6 +2101,10 @@signal_description (c->sig->signal_received, c->sig->signal_text), "route-pre-down", c->c2.es); +if (c->mode ==CM_P2P && c->options.persist_tun) + { +del_route_towards_remote (c); + }delete_routes (c->c1.route_list, c->c1.route_ipv6_list, c->c1.tuntap,ROUTE_OPTION_FLAGS (&c->options), c->c2.es, &c->net_ctx); }
@@ -2145,6 +2149,11 @@ c->c2.es); } +if (c->mode ==CM_P2P && c->options.persist_tun) + { +del_route_towards_remote (c); + } +del_wfp_block (c, adapter_index); }gc_free (&gc);
@@ -4714,6 +4723,17 @@ } } +/** +* When using both --redirect-gateway and --persist-tun, +* if the connection to the server is lost, a /32 (or /128 if IPv6) route must be added +* to ensure connectivity to the next remote. +*/ +if (c->mode ==CM_P2P + && c->options.persist_tun) + { +add_route_towards_remote (c); + } +/* * Actually do UID/GID downgrade, and chroot, if requested. * May be delayed by --client, --pull, or --up-delay.
src/openvpn/route.c +156 -22
218 lines not on this page · raw message
src/openvpn/route.h +11 -0
@@ -309,6 +309,14 @@ const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx); +/* Function to add a route towards the new remote when using +* `--redirect-gateway` and `--persist-tun` options together. */ +void add_route_towards_remote (struct context *c); + +/* Function to delete the route towards the remote when using +* `--redirect-gateway` and `--persist-tun` options together. */ +void del_route_towards_remote (struct context *c); +void add_route_to_option_list (struct route_option_list *l,const char *network,const char *netmask,const char *gateway,const char *metric,int table_id);
@@ -359,6 +367,9 @@void print_default_gateway (const int msglevel,const struct route_gateway_info *rgi,const struct route_ipv6_gateway_info *rgi6); +/* Return a `route_ipv6 *` /128 IPv6 route toward the remote host */ +struct route_ipv6 *create_host_route_ipv6 (struct in6_addr remote_host_ipv6,struct route_ipv6_list *rl6); +/* * Test if addr is reachable via a local interface (return ILA_LOCAL), * or if it needs to be routed via the default gateway (return
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7b486ccb85df7fc1d6a573ac1315d235728822c
Gerrit-Change-Number: 901
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, mrbff, plaisthos.
stipa has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/901?usp=email )
Change subject: redirect-gateway: add route toward new remote host when using persist-tun
......................................................................
Patch Set 3:
(1 comment)
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/901/comment/1a8b4adf_ca79cad5?usp=email :
PS3, Line 1230: int current_remote_family = c->c1.link_socket_addrs[0].actual.dest.addr.sa.sa_family;
Can we factor out c->c1.link_socket_addrs[0].actual.dest.addr into its own variable? We use this long statement in 3 places in this function.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7b486ccb85df7fc1d6a573ac1315d235728822c
Gerrit-Change-Number: 901
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Wed, 15 Oct 2025 12:47:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: flichtenheld, mrbff, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
to look at the new patch set (#4).
Change subject: redirect-gateway: add route toward new remote host when using persist-tun
......................................................................
redirect-gateway: add route toward new remote host when using persist-tun
When both --redirect-gateway and --persist-tun are used together, a route must be added for each new remote host we attempt to connect to.
---
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
3 files changed, 189 insertions(+), 22 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/901/4
src/openvpn/init.c +20 -0
@@ -2106,6 +2106,10 @@signal_description (c->sig->signal_received, c->sig->signal_text), "route-pre-down", c->c2.es); +if (c->mode ==CM_P2P && c->options.persist_tun) + { +del_route_towards_remote (c); + }delete_routes (c->c1.route_list, c->c1.route_ipv6_list, c->c1.tuntap,ROUTE_OPTION_FLAGS (&c->options), c->c2.es, &c->net_ctx); }
@@ -2150,6 +2154,11 @@ c->c2.es); } +if (c->mode ==CM_P2P && c->options.persist_tun) + { +del_route_towards_remote (c); + } +del_wfp_block (c, adapter_index); }gc_free (&gc);
@@ -4723,6 +4732,17 @@ } } +/** +* When using both --redirect-gateway and --persist-tun, +* if the connection to the server is lost, a /32 (or /128 if IPv6) route must be added +* to ensure connectivity to the next remote. +*/ +if (c->mode ==CM_P2P + && c->options.persist_tun) + { +add_route_towards_remote (c); + } +/* * Actually do UID/GID downgrade, and chroot, if requested. * May be delayed by --client, --pull, or --up-delay.
src/openvpn/route.c +158 -22
220 lines not on this page · raw message
src/openvpn/route.h +11 -0
@@ -309,6 +309,14 @@ const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx); +/* Function to add a route towards the new remote when using +* `--redirect-gateway` and `--persist-tun` options together. */ +void add_route_towards_remote (struct context *c); + +/* Function to delete the route towards the remote when using +* `--redirect-gateway` and `--persist-tun` options together. */ +void del_route_towards_remote (struct context *c); +void add_route_to_option_list (struct route_option_list *l,const char *network,const char *netmask,const char *gateway,const char *metric,int table_id);
@@ -359,6 +367,9 @@void print_default_gateway (const msglvl_t msglevel,const struct route_gateway_info *rgi,const struct route_ipv6_gateway_info *rgi6); +/* Return a `route_ipv6 *` /128 IPv6 route toward the remote host */ +struct route_ipv6 *create_host_route_ipv6 (struct in6_addr remote_host_ipv6,struct route_ipv6_list *rl6); +/* * Test if addr is reachable via a local interface (return ILA_LOCAL), * or if it needs to be routed via the default gateway (return
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7b486ccb85df7fc1d6a573ac1315d235728822c
Gerrit-Change-Number: 901
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos, stipa.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/901?usp=email )
Change subject: redirect-gateway: add route toward new remote host when using persist-tun
......................................................................
Patch Set 3:
(1 comment)
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/901/comment/40ae9d7e_94ecf070?usp=email :
PS3, Line 1230: int current_remote_family = c->c1.link_socket_addrs[0].actual.dest.addr.sa.sa_family;
Quoted 1 line
Can we factor out c->c1.link_socket_addrs[0].actual.dest. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/901?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7b486ccb85df7fc1d6a573ac1315d235728822c
Gerrit-Change-Number: 901
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 15 Oct 2025 18:37:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: stipa <[email protected]...>